<?php
/*
 BMForum Datium! Bulletin Board Systems
 Version : Datium!
 
 This is a freeware, but don't change the copyright information.
 A SourceForge Project.
 Web Site: http://www.bmforum.com
 Copyright (C) Bluview Technology
*/

// ===================================
// Sub Forum (row)
// ===================================

function forum_line_row($forum_type, $line, $allline)
{
    global $detail, $bmforumlist, $forums_stat, $bmfopt, $forum_line, $popp, $bbsdetime, $replaces_a, $replaces_c, $th_arr, $replaces_b, $replaces_d, $leiji, $preoutput_row, $xxxcount, $forumlist, $preoutput, $po, $temfilename, $all_count, $all_lastmo, $time_2, $time_1, $script_pos, $forum_admin, $login_status, $idpath, $newpost, $onlyread, $nonewpost, $posticon, $pollicon, $ucomicon, $otherimages, $timestamp, $minoffset;

    $ztnum = 0;
    $ztnum1 = 0;

    $ztnum = $line['topicnum'];
    $ztnum1 = $line['replysnum'];
    $ztnum2 = $line['todayp'];

    $lasttodaytime = gmdate("zY", $line['todaypt'] + $bbsdetime * 60 * 60);
    $lasttodaytime_a = gmdate("zY", $timestamp + $bbsdetime * 60 * 60);
    
    if ($lasttodaytime != $lasttodaytime_a) {
    	$ztnum2 = 0;
    }
    
    for($ax = 0;$ax < $xxxcount;$ax++) {
        if ($allline[$ax]['blad'] == $line['id']) {
            $ztnum += $allline[$ax]['topicnum'];
            $ztnum1 += $allline[$ax]['replysnum'];
            $lasttodaytime = gmdate("zY", $allline[$ax]['todaypt'] + $bbsdetime * 60 * 60);
            
            if ($lasttodaytime == $lasttodaytime_a) {
                $ztnum2 += $allline[$ax]['todayp'];
            }

        } 
    } 

    $forumlabel = "<span class='forumnamelink'><a title=\"{$line['cdes']}\" onfocus='this.blur()'  href=\"".($bmfopt['rewrite'] ? "forums_{$line['id']}" : "forums.php?forumid={$line['id']}")."\"> {$line['bbsname']} </a></span>";

    if (!empty($line['adminlist'])) {
        $forum_admin = explode("|", $line['adminlist']);
        $count = count($forum_admin)-1;
        for ($j = 0; $j < $count; $j++) {
            $adminname = $forum_admin[$j];
            $admin_list_row .= " <a title=\"$forum_line[12] $adminname $forum_line[13]\" href=\"profile.php?job=show&amp;target=" . urlencode($adminname) . "\">$adminname</a></span> ";
        } 
    } 
    
    if ($line['forum_icon'] <> "") $line['forum_icon'] = "<img src='{$line['forum_icon']}' alt='' />";

    $detail[5] = $popp[14] . " " . $admin_list_row;
    $ztnum = "$popp[15] $ztnum / $popp[16] $ztnum1 / $popp[23] $ztnum2";

    $forums_stat++;
    
   	$bmforumlist[] = array("ROWF"=>1,"admin_list_row" => $detail[5], "ztnum" => $ztnum, "forum_icon" => $line['forum_icon'], "forumdes" => $line['cdes'], "forumlabel" => $forumlabel, "TYPE"=> "forum", "ID" => $line['id']);

} 
// ===================================
// Sub Forum
// ===================================
function forum_line($forum_type, $line)
{
    global $detail, $bmfopt, $bmforumlist, $infoan, $enter_tb, $bbsdetime, $listmmlist, $fastmanage, $preoutput, $temfilename, $t, $po, $time_2, $forum_line, $usertype, $script_pos, $forum_admin, $login_status, $idpath, $newpost, $onlyread, $nonewpost, $posticon, $pollicon, $ucomicon, $otherimages, $timestamp, $minoffset;
    $aviewpost = $line['naviewpost'];
    if ($aviewpost == "openit") {
        $filetopn = "article.php";
    } else {
        $filetopn = "topic.php";
    } 
    if ($listmmlist == 1) $admin_list_2 = "<select onchange='javascript:window.location=this.value' style='width: 100px'>";
    if (!empty($line['adminlist'])) {
        $forum_admin = explode("|", $line['adminlist']);
        $count = count($forum_admin)-1;
        for ($j = 0; $j < $count; $j++) {
            $adminname = $forum_admin[$j];
            if ($listmmlist == 1) {
                $hasadmin = 1;
                if ($adminname != "") $admin_list_2 .= "<option value=\"profile.php?job=show&amp;target=" . urlencode($adminname) . "\">$adminname</option>";
            } else $admin_list_2 .= "<a title=\"$forum_line[0] $adminname $forum_line[1]\" href=\"profile.php?job=show&amp;target=" . urlencode($adminname) . "\">$adminname</a>";
            if ($j != $count-1) $admin_list_2 .= ",";
            $admin_list_2_row .= " <a title=\"$forum_line[0] $adminname $forum_line[1]\" href=\"profile.php?job=show&amp;target=" . urlencode($adminname) . "\">$adminname</a> ";
        } 
    } 
    if ($hasadmin != 1 && $listmmlist == 1) $admin_list_2 .= "<option value=''>$infoan[1]</option>";
    if ($listmmlist == 1) $admin_list_2 .= "</select>";
    if ($line['forum_icon'] <> "") $line['forum_icon'] = "<img src='{$line['forum_icon']}' alt='' />";

    $line['fltitle'] = stripslashes($line['fltitle']);
    $lastmodify_title = $line['fltitle'];
    if (utf8_strlen($line['fltitle']) >= 12) $line['fltitle'] = substrfor($line['fltitle'], 0, 12) . "..";
    $modifytime = $line['flposttime'];
    if ($modifytime!="") {
        $line['flposttime'] = getfulldate($modifytime);
    }
    $line['fltitle'] = htmlspecialchars($line['fltitle']);
    
    if ($time_2) {
        $timetmp_a = $timestamp - $modifytime;
        $timetoshow = get_add_date($timetmp_a);
        if ($timetoshow == "getfulldate") {
            $timetoshow = $line['flposttime'];
        } 
    } else {
        $timetoshow = $line['flposttime'];
    } 
    
    $title = "<a title=\"{$lastmodify_title} - {$line['flposter']}\" href=\"".(($bmfopt['rewrite'] && $filetopn == "topic.php") ? "topic_{$line['flfname']}_last#postend" : "$filetopn?getlastpost=yes&amp;ct={$line['flfname']}&amp;forumid={$line['id']}&amp;page=last")."\">{$line['fltitle']}</a>";
    $user = "<a href=\"profile.php?job=show&amp;target=" . urlencode($line['flposter']) . "\">{$line['flposter']}</a> <a href='".(($bmfopt['rewrite'] && $filetopn == "topic.php") ? "topic_{$line['flfname']}" : "$filetopn?getlastpost=yes&amp;ct={$line['flfname']}&amp;forumid={$line['id']}")."' title=\"$forum_line[11]\"><img border='0' src='$otherimages/system/lastpost.gif' alt='' /></a>";
    $time = $timetoshow;
    
    
    
    if ($forum_type == "subforum" || $forum_type == "subformer" || $forum_type == "subforumhid") {
        $last_modify_list_time_check = explode(" ", $line['flposttime']);
        $last_modify_list_time_check = explode("-", $last_modify_list_time_check[0]);
        $nowdatetime = get_date($timestamp);
        $nowdatetime_check = explode("-", $nowdatetime); 
        // ----- is there any new post? ------
        // echo $lastvisit;echo $lastvisit-$modifytime;
        if ($nowdatetime_check[1] == $last_modify_list_time_check[1] && $nowdatetime_check[2] == $last_modify_list_time_check[2] && $nowdatetime_check[0] == $last_modify_list_time_check[0]) $forum_icon = '<img src="' . $newpost . '" border="0" alt="" />';
        else $forum_icon = '<img src="' . $nonewpost . '" border="0" alt="" />';
    } else $forum_icon = '<img src="' . $onlyread . '" border="0" alt="" />';
    $forumlabel = "<span class='forumnamelink'><a onfocus='this.blur();' href=\"".($bmfopt['rewrite'] ? "forums_{$line['id']}" : "forums.php?forumid={$line['id']}")."\"> {$line['bbsname']} </a></span>";
    
    if ($forum_type == 'sublocked' && !$enter_tb) {
        $title = "";
    } 

    $ztnum = $line['topicnum'];
    $ztnum1 = $line['replysnum'];
    $ztnum2 = $line['todayp'];

    $lasttodaytime = gmdate("zY", $line['todaypt'] + $bbsdetime * 60 * 60);
    $lasttodaytime_a = gmdate("zY", $timestamp + $bbsdetime * 60 * 60);
    
    if ($lasttodaytime != $lasttodaytime_a) {
    	$ztnum2 = 0;
    }
    
    $bmforumlist[] = array("teamicon"=> $line['forum_icon'], "filetopn" => $filetopn, "subforums" => $tsubforum, "user" => $user, "admin_list" => $admin_list_2, "admin_list_row" => $admin_list_2_row, "time" => $time, "title" => $title, "ztnum2" => $ztnum2, "ztnum1" => $ztnum1, "ztnum" => $ztnum, "forum_des" => $line['cdes'], "forum_icon" => $forum_icon,"forumlabel" => $forumlabel, "TYPE"=> "forum", "ID" => $line['id'],"NAME"=>$line['bbsname'], "CLIST"=>$clist);

//    $replaces = array("{filetopn}" => $filetopn, "{user}" => $user, "{admin_list_2}" => $admin_list_2, "{admin_list_2_row}" => $admin_list_2_row, "{time}" => $time, "{title}" => $title, "{ztnum2}" => $ztnum2, "{ztnum1}" => $ztnum1, "{ztnum}" => $ztnum, "{detail[1]}" => $line['bbsname'], "{detail[2]}" => $line['cdes'], "{detail[3]}" => $line['id'], "{detail[5]}" => $line['forum_icon'], "{forum_icon}" => $forum_icon, "{forumlabel}" => $forumlabel);
} 
// ===================================
// article list display
// ===================================
function article_line($a_info)
{
    global $atrlistat, $hereis_top, $topinfooutput, $bmfopt, $page, $allow_ajax_reply, $hasatopic, $fastmanage, $allinfooutput, $emotrand, $forum_cid, $quinfooutput, $database_up, $atrlistt, $atrlistvt, $forumid, $time_2, $filetopn, $forum_mang_t, $coninfo, $forum_cid, $listfilename, $username, $read_perpage, $timestamp, $login_status, $forum_admin, $admin_name, $idpath, $otherimages, $usertype;
    // list($title,$author,$date,$des,$icon,$filename,$reply,$hit,$last_mod_data,$islock,$topic_type)=explode("|",$a_info);
    $hasatopic = 1; // Check topics
    $filename = $a_info[id];
    $reply = $a_info[replys];
    $topic_type = trim($a_info[type]);
    $topic_islock = trim($a_info[islock]);
    if ($a_info['addinfo']) {
        list($moveinfo, $isjztitle) = explode("|", $a_info['addinfo']);
        list($isjztitle, $isjzcolor, $jiacu, $shanchu, $xiahuau, $xietii, $bgcolorcode, $fontsize) = explode(",", $isjztitle);
        $moveinfo = "<strong><span class=\"jiazhongcolor\">$moveinfo</span></strong>";
    } 
    // ///
    if ($fastmanage == 1 && $login_status == 1 && (($forum_admin && in_array($username, $forum_admin)) || $usertype[22] == "1" || $usertype[21] == "1")) {
        if ($listfilename == "ttrash") {
            $toplangg = "|<a href='misc.php?p=manage&amp;action=del&amp;filename=$filename'>$forum_mang_t[19]</a>";
            $toplangg .= "|<a href='misc.php?p=rtrash&amp;action=move&amp;filename=$filename'>$forum_mang_t[20]</a>";
        } else {
            $toplangg = "|<a href='misc.php?p=manage&amp;action=del&amp;filename=$filename'>$forum_mang_t[0]</a>|";
            if ($topic_islock != 1 && $topic_islock != 3) $toplangg .= "<a href='misc.php?p=manage&amp;action=lock&amp;filename=$filename'>$forum_mang_t[1]</a>";
            else $toplangg .= "<a href='misc.php?p=manage&amp;action=unlock&amp;filename=$filename'>$forum_mang_t[2]</a>";
            if ($topic_islock == 0 || $topic_islock == 1) $toplangg .= "|<a href='misc.php?p=manage&amp;action=jihua&amp;filename=$filename'>$forum_mang_t[21]</a>";
            else $toplangg .= "|<a href='misc.php?p=manage&amp;action=unjihua&amp;filename=$filename'>$forum_mang_t[22]</a>";
            $toplangg .= "|<a href='misc.php?p=manage&amp;action=move&amp;filename=$filename'>$forum_mang_t[3]</a>";
            $toplangg .= "|<a href='misc.php?p=manage3&amp;action=move&amp;newforumid=trash&amp;filename=$filename'>$forum_mang_t[4]</a>";
            $toplangg .= "|<a href='misc.php?p=manage2&amp;action=btfront&amp;filename=$filename'>$forum_mang_t[6]</a>";
            if ($a_info['toptype'] != 9) {
                $toplangg .= "|<a href='misc.php?p=topsys&amp;job=write&amp;step=2&amp;foruid=$forumid&amp;topid=$filename'>$forum_mang_t[7]</a>";
            } elseif ($a_info['toptype'] == 9) {
                $toplangg .= "|<a href='misc.php?p=topsys&amp;job=delone&amp;step=2&amp;foruid=$forumid&amp;topid=$filename'>$forum_mang_t[7]</a>";
            } 
            if ($a_info['toptype'] != 8) {
                $toplangg .= "|<a href='misc.php?p=catesys&amp;cateid=$forum_cid&amp;job=write&amp;step=2&amp;foruid=$forumid&amp;topid=$filename'>$forum_mang_t[8]</a>";
            } elseif ($a_info['toptype'] == 8) {
                $toplangg .= "|<a href='misc.php?p=catesys&amp;cateid=$forum_cid&amp;job=delone&amp;step=2&amp;foruid=$forumid&amp;topid=$filename'>$forum_mang_t[8]</a>";
            } 
            if ($topic_type >= 3) $toplangg .= "|<a href='misc.php?p=manage2&amp;action=unhold&amp;filename=$filename'>$forum_mang_t[9]</a>|";
            else $toplangg .= "|<a href='misc.php?p=manage2&amp;action=holdfront&amp;filename=$filename'>$forum_mang_t[10]</a>|";
            if ($isjztitle == "0" || $isjztitle == "") $toplangg .= "<a href='misc.php?p=manage5&amp;action=add&amp;filename=$filename'>$forum_mang_t[11]</a>|";
            else $toplangg .= "<a href='misc.php?p=manage5&amp;action=cancel&amp;filename=$filename'>$forum_mang_t[12]</a>|";
        } 
    } 
    if (utf8_strlen($a_info[author]) >= 12) $viewauthor = substrfor($a_info[author], 0, 9) . '...';
    else $viewauthor = $a_info[author];
    $icon = $a_info[face];

    if (($icon == "ran" || $icon == "") && $emotrand == 1) {
        $icon = mt_rand(0, 52) . '.gif';
        $icon = "<a target='_blank' href='$filetopn?filename=$filename'><img src='images/emotion/$icon' alt='$forum_mang_t[13]' border='0' /></a>";
    } elseif (($icon == "ran" || $icon == "") && $emotrand != 1) {
        $icon = "&nbsp;";
    } else {
        $icon = "<a target='_blank' href='$filetopn?filename=$filename'><img src='images/emotion/$icon' alt='$forum_mang_t[13]' border='0' /></a>";
    } 
    if ($topic_type == 1) {
        $stats = "<img src='$otherimages/system/statistic.gif' border='0' alt='' />";
        if ($topic_islock == 1 || $topic_islock == 3) $stats = "<img src='$otherimages/system/closesta.gif' border='0' alt='' />";
    } elseif ($topic_type >= 3) {
        $stats = "<img src='$otherimages/system/holdtopic.gif' border='0' alt='' />";
    } else {
        if ($username != $a_info[author]) {
            $stats = "<img src='$otherimages/system/topicnew.gif' border='0' alt='' />";
            if ($reply >= 10) $stats = "<img src='$otherimages/system/topichot.gif' border='0' alt='' />";
            if ($topic_islock == 1 || $topic_islock == 3) $stats = "<img src='$otherimages/system/topiclocked.gif' border='0' alt='' />";
        } else {
            $stats = "<img alt='($forum_mang_t[14])' src='$otherimages/system/mytopicnew.gif' border='0' />";
            if ($reply >= 10) $stats = "<img alt='($forum_mang_t[14])' src='$otherimages/system/mytopichot.gif' border='0' />";
            if ($topic_islock == 1 || $topic_islock == 3) $stats = "<img alt='($forum_mang_t[14])' src='$otherimages/system/mytopiclocked.gif' border='0' />";
        } 
    } 
    // -------if more than one page-----------
    if ($reply + 1 > $read_perpage) {
        if (($reply + 1) % $read_perpage == 0) $maxpageno = ($reply + 1) / $read_perpage;
        else $maxpageno = floor(($reply + 1) / $read_perpage) + 1;
        $multipage = '[ <img alt="' . $forum_mang_t[15] . '" src="' . $otherimages . '/mpages.gif" /><strong><span class="forum_page_links">';
        for ($i = 1; $i <= $maxpageno; $i++) {
            $multipage .= " <a href=\"".(($bmfopt['rewrite'] && $filetopn == "topic.php") ? "topic_{$filename}_$i" : "$filetopn?forumid=$forumid&amp;filename=$filename&amp;page=$i&amp;extra=page%3D$page")."\">$i</a>";
            if ($i == 5) {
                $multipage .= " ... <a href=\"".(($bmfopt['rewrite'] && $filetopn == "topic.php") ? "topic_{$filename}_last" : "$filetopn?forumid=$forumid&amp;filename=$filename&amp;page=last&amp;extra=page%3D$page")."\">$maxpageno</a>";
                break;
            } 
        } 
        $multipage .= '</span></strong> ' . $forum_mang_t[16] . ']';
    } 
    // /
    $titlelong = stripslashes($a_info[title]);
    $title = stripslashes($a_info[title]);

    if ($a_info['other3']) $title = '<img src="images/attach/attach.gif" border="0" alt="" />' . $title;

    if ($allow_ajax_reply && $login_status == 1 && ($username == $a_info["author"] || ($forum_admin && in_array($username, $forum_admin)) || $usertype[22] == "1" || $usertype[21] == "1")) {
        $ajaxscript = "title=\"$coninfo[19]\" ondblclick=\"bmb_ajax_tabletitle('tname$filename','$filename','$coninfo[18]','$filetopn');\" ";
        $ajaxinfo = "<script type='text/javascript'>tname['$filename'] = '". str_replace("'", "\'", $titlelong) ."';</script>";
    }

    $font_css .= $jiacu ? "font-weight: bold;" : "";
    
    if ($xiahuau && $shanchu) $font_css .= "text-decoration: line-through underline;";
      else {
        $font_css .= $shanchu ? "text-decoration: line-through;" : "";
        $font_css .= $xiahuau ? "text-decoration: underline;" : "";
      }
    $font_css .= $xietii ? "font-style: italic;" : "";
    $font_css .= $bgcolorcode ? "background-color: $bgcolorcode;" : "";
    $font_css .= $fontsize ? "font-size: {$fontsize}pt;" : "";
    

    if ($isjztitle == "1") {
        if (!empty($isjzcolor)) {
            $font_css .= "color: $isjzcolor;";
        } 
    } 
    
    if ($font_css) $title = "<span style=\"$font_css\">$title</span>";
    
    if ($bmfopt['display_ftag'] && $a_info['ttagname']) {
    	$tag_list = explode(" ", $a_info['ttagname']);
    	$first_tag_name	= $tag_list[0];
    	$url_tag_name	= urlencode($first_tag_name);
    	$first_tag_mark = "<span class='f_tags_link'><a href='plugins.php?p=tags&amp;tagname=$url_tag_name'>[$first_tag_name]</a></span>&nbsp;";
    }

    if (!empty($a_info[newdesc])) $desshow = "\n$a_info[newdesc]";
    $title = "{$first_tag_mark}<span id='t$filename'><a onfocus='this.blur()' href='".(($bmfopt['rewrite'] && $filetopn == "topic.php") ? "topic_{$filename}" : "$filetopn?filename=$filename&amp;extra=page%3D$page")."' title=\"$coninfo[4]\n{$titlelong}$desshow\">$title</a></span>";
    $lmd = explode(",", $a_info[lastreply]);
    $g = $timestamp - $lmd[2];
    if ($g <= 3600) $title .= '  <img src="' . $otherimages . '/system/newred.gif" alt="" />';
    elseif ($g <= 86400) $title .= '  <img src="' . $otherimages . '/system/newblue.gif" alt="" />';
    elseif ($g <= 172800) $title .= '  <img src="' . $otherimages . '/system/newgreen.gif" alt="" />';
    if ($topic_islock == 2 || $topic_islock == 3) $title .= "  <img title=\"$forum_mang_t[17]\" src=\"$otherimages/system/jhinfo.gif\" alt='' />";
    if ($lmd[2] == $date) $lmdauthor = "$forum_mang_t[18]";
    else $lmdauthor = "<a href=\"profile.php?job=show&amp;target=" . urlencode($lmd[1]) . "\">$lmd[1]</a>";
    $lmdtime_tmp = get_date($lmd[2]) . ' ' . get_time($lmd[2]);
    $cmdtime_tmp = get_date($a_info[time]);
    if ($time_2) {
        $timetmp_a = $timestamp - $lmd[2];
        $timetoshow = get_add_date($timetmp_a);
        if ($timetoshow == "getfulldate") {
            $timetoshow = $lmdtime_tmp;
        } 
        $timedmp_b = $timestamp - $a_info[time];
        $aimetoshow = get_add_date($timedmp_b);
        if ($aimetoshow == "getfulldate") {
            $aimetoshow = $cmdtime_tmp;
        } 
    } else {
        $timetoshow = $lmdtime_tmp;
        $aimetoshow = $cmdtime_tmp;
    } 
    $hit = $a_info[hits];
    $urlauthor = urlencode($a_info[author]);

    if ($a_info['toptype'] == 9) {
        $stats = "<img src='$otherimages/announce.gif' border='0' alt=''/>";
    } elseif ($a_info['toptype'] == 8) {
        $stats = "<img src='$otherimages/system/lockcattop.gif' border='0' alt=''/>";
    } 
    if ($a_info['other1'] != 0) $a_info['other1'] = floor($a_info['other1']/10);
    if ($a_info['other1'] > 0) {
    	$pin_score = "<img src='$otherimages/hand2.gif' border='0' alt='+{$a_info['other1']}' title='+{$a_info['other1']}' />";
    } elseif ($a_info['other1'] < 0) {
    	$pin_score = "<img src='$otherimages/hand.gif' border='0' alt='{$a_info['other1']}' title='{$a_info['other1']}' />";
    }


   
    $linktothread = ($bmfopt['rewrite'] && $filetopn == "topic.php") ? "topic_{$filename}" : "$filetopn?forumid=$forumid&amp;filename=$filename";

    $replacas = array("a_toptype" => $a_info['toptype'], "scores_change" => $other1, "pin_score" => $pin_score, "stats" => $stats, "listfilename" => $listfilename, "filename" => $filename, "linktothread" => $linktothread, "ajaxinfo" => $ajaxinfo, "ajaxscript" => $ajaxscript, "filename" => $filename, "icon" => $icon, "urlauthor" => $urlauthor, "hit" => $hit, "multipage" => $multipage, "title" => $title, "toplangg" => $toplangg, "aimetoshow" => $aimetoshow, "moveinfo" => $moveinfo, "viewauthor" => $viewauthor, "reply" => $reply, "lmdauthor" => $lmdauthor, "timetoshow" => $timetoshow);

    if ($a_info['toptype'] == 9) {
    	$hereis_top = 1;
        $topinfooutput[]= $replacas;
    } elseif ($a_info['toptype'] == 8) {
    	$hereis_top = 1;
        $quinfooutput[]= $replacas;
    } else {
        $allinfooutput[]= $replacas;
    } 
	
} 
// ===================================
// online
// ===================================
function whosonline()
{
    global $timestamp, $whois_online, $unshowit, $view_index_online, $forum_picie, $online_show, $t, $online_limit, $see_amuser, $usergroupdata, $po, $temfilename, $forumid, $online_info_show, $admin_list, $admin_name, $otherimages, $username, $id_unique;
    $onlinefile = "datafile/online.php";
    $guestno = 0;
    $guestfile = readfromfile("datafile/guest.php");
    $guestno = count(explode("|f|$forumid|", $guestfile)) - 1;;
    $usernoc = 0;
    $userno = 0;
    $usergroup = '';
    $online_user_real = $online_user = file($onlinefile);
    
    if ($unshowit[6] != 1) {
    	$guestfile = explode("\n", $guestfile);
    	$online_user = array_merge((array)$online_user,(array)$guestfile);
    }
    

    $idd = 1;
    $count = count($online_user);
    if (($online_show == "" && $view_index_online == "1") || $online_show == show) {
        for ($i = 0; $i < $count; $i++) {
            $addproinfo = "";
            $online_user_info = explode("|", trim($online_user[$i]));
            if ($timestamp - $online_user_info[2] <= $online_limit && $online_user_info[5] == $forumid) {
				if ($online_user_info[11] == "yes") $usernoc++;
                if ($online_user_info[11] != "yes" || ($online_user_info[11] == "yes" && $see_amuser == 1)) {
                    $idd++;
                    
                    if (($online_show == "" && $view_index_online == "1") || $online_show == "show") {
                        if ($online_user_info[11] == "yes") $addproinfo = " ($online_info_show[1])";
                        
                        $br = "";
                        if (floor($idd / 7) * 7 == $idd) {
                            $br = "</tr><tr>";
                        } 
                        
		            	if ($unshowit[6] != 1 && ($now_guest == 1 || trim($online_user_info[10]) == "")) {
		            		if ($now_guest != 1) {
		                    	$usertype = explode("|", $usergroupdata[6]);
		            			$now_guest = 1;
		            		}
	                        $usergroup .= "<td width='12%'>&nbsp;<img border='0' src='$otherimages/system/{$usertype[1]}' /> $online_user_info[1]</span></td>$br";
		            	} else {
		                    $usertype = explode("|", $usergroupdata[$online_user_info[10]]);
	                        $usergroup .= "<td width='12%'>&nbsp;<a  href=\"messenger.php?job=write&amp;target=" . urlencode($online_user_info[1]) . "\"><img alt=\"$online_info_show[2]{$usertype[0]}$online_info_show[3]\" border='0' src='$otherimages/system/{$usertype[1]}' /></a> <a title=\"$online_info_show[4]{$usertype[0]}$online_info_show[5] $addproinfo\" href='profile.php?job=show&amp;target=" . urlencode($online_user_info[1]) . "'>$online_user_info[1]</a></span></td>$br";
	                    }
                        
                    }
                    if ($now_guest != 1 && $online_user_info[11] != "yes") $userno++;
                } 
            } 
        } 
    } else {
    	
        $online_user_content = implode("" ,$online_user_real);
        $userno = count(explode("|f|$forumid|", $online_user_content)) - 1;
        
    }
    if (($online_show == "" && $view_index_online == "1") || $online_show == "show") {
    	$online_show_anti = "hide";
    } else {
    	$online_show_anti = "show";
    }
    if ($usergroup) $usergroup = "<tr><td class='list_color2'><table width='100%'><tr>$usergroup</table></td></tr>";
    $suma = $userno + $usernoc;
    $sum = $userno + $guestno + $usernoc;
	$whois_online = array("sum" => $sum, "online_show_anti" => $online_show_anti, "suma" => $suma, "usernoc" => $usernoc, "guestno" => $guestno, "usergroup" => $usergroup);

} 
function fast_new ()
{
	global $emot_every, $fast_post, $forumid, $usertype, $set_a_tags, $html_codeinfo, $login_status, $username, $max_upload_size, $max_daily_upload_size, $uploadfiletoday, $min_post_length, $max_post_length, $emot_lines, $max_upload_post, $allow_upload, $upload_type_available, $forum_pos;
    // ------ Emoticons -------
    if (file_exists("datafile/emoticon.php")) {
        $emotfile = "datafile/emoticon.php";
        $emotfiledata = file($emotfile);
    } 
    
    $count = count($emotfiledata) + 1;
    $emot_max = $emot_lines * $emot_every + 1;
    if ($count > $emot_max) $count = $emot_max;
    
    $wemotinfoshow = '';

    for ($i = 1;$i < $count;$i++) {
        $ci = $i-1;
        $br = "";
        $emotfd = explode("＊＊", $emotfiledata[$ci]);
        if ($emotfd[2] == 1) $emotfd[1] = "thumb/$emotfd[1]";
        if ((floor($i / $emot_every) * $emot_every) == $i) $br = "<br />";
        $wemotinfoshow .= "<img onclick=\"javascript:AddText('$emotfd[0]');\" src=\"images/face/$emotfd[1]\" alt='' />$br";
    } 

    // ------ Upload ----------
    if ($allow_upload) {
        $available_ext = explode(' ', $upload_type_available);
        $extcount = count($available_ext);
        $showtype = "<select><option value=''>$forum_pos[18]</option><option value=''>---------</option>";
        for ($i = 0; $i < $extcount; $i++) {
            $showtype .= "<option value=''>$available_ext[$i]</option>";
        } 
        $showtype .= "</select>";
        $showuploads = "<input size=\"55\" onchange=\"javascript:check_file_ext(this,$extcount);\" type=\"file\" name=\"attachment[]\" /> $showtype";
    } 
    if ($allow_upload) $uploadinfoshow = ' ' . $forum_pos[19] . '</strong><br />' . $forum_pos[20] . $max_upload_size . $forum_pos[21] . '<br />
	' . $forum_pos[22] . $max_upload_post . $forum_pos[23] . '</font><br />';
    else $uploadinfoshow = " $forum_pos[6]</strong>";


    $leftuploadnum = $max_daily_upload_size - $uploadfiletoday;
    if ($html_codeinfo != "yes") {
        $htmlcodeinfo = "<input type='checkbox' name='' disabled='disabled' value='checkbox' id='closedhtml' /><label for='closedhtml'><strong>$forum_pos[24]</strong></label><br />";
    } else {
        $htmlcodeinfo = '<input type="checkbox" name="openhtmlcode" value="checkbox" id="open_1" /><label for="open_1">' . $forum_pos[6] . '<strong>HTML Code</strong></label><br />';
    } 

    $dbgcolor = "article_color1";
    
    if (file_exists("datafile/actinfo.php")) {
        $filedata = file("datafile/actinfo.php");
        $count = count($filedata);
        for ($i = 0;$i < $count;$i++) {
            list($act, $actinfo) = explode("|", $filedata[$i]);
            $acta = str_replace("/", "", $act);
            $actshows .= "<option value='$act'>$acta</option>";
        } 
    } 
    if ($postdontadd == "1") {
        $tmpa = "$forum_picie[31]";
    } else {
        $tmpa = "$forum_picie[30]";
    } 
    if ($guestpost == "1") {
        $tmpb = "$forum_picie[30]";
    } else {
        $tmpb = "$forum_picie[31]";
    } 

    $showinfoofforum = "{$forum_picie[32]}$tmpa {$forum_picie[33]}$tmpb";
    if ($login_status == 0) { // 开关
        $addinfoone = '<br />' . $forum_pos[25] . '<input maxlength="25" size="15" tabindex="1" name="username" /><br />' . $forum_pos[26] . '<input tabindex="2" maxlength="25" size="15" name="password" type="password" />';
    } 
    
    $usertype_z = $usertype[110];
    
    if ($set_a_tags == 1) {
        $chooser_c = "<select name='tags' style='width: 50px'><option value=''>Tags</option>";
	    @include("datafile/cache/tags_topic.php");

	    $tags_topic_list = explode("\n", ($tags_tlist[$forumid] ? $tags_tlist[$forumid] : $tags_tlist['tags_solid']));
	    for($til = 0;$til<count($tags_topic_list);$til++){
	    	$chooser_c .= "<option value='$tags_topic_list[$til]'>$tags_topic_list[$til]</option>";
	    }
	    
	    $chooser_c .= "</select>&nbsp;";

    }

   $fast_post = array("extcount" => $extcount, "usertype_z" => $usertype_z, "chooser_c" => $chooser_c, "wemotinfoshow" => $wemotinfoshow, "showinfoofforum" => $showinfoofforum, "dbgcolor" => $dbgcolor, "htmlcodeinfo" => $htmlcodeinfo, "codeinfoc" => $codeinfoc, "uploadinfoshow" => $uploadinfoshow, "leftuploadnum" => $leftuploadnum, "actshows" => $actshows, "showuploads" => $showuploads, "addinfoone" => $addinfoone);
}
